package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    //新增套餐
    @AutoFill(OperationType.INSERT)
    void addSetmeal(Setmeal setmeal);

    //套餐分页查询
    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    //根据id查询套餐信息
    @Select("select * from setmeal where id=#{id}")
    Setmeal setmealById(Long id);

    //删除套餐
    void delete(List<Long> ids);

    //停售或启售套餐
    @Update("update setmeal set status=#{status} where id=#{id}")
    void setSetmealStatus(Integer status, Long id);

    //修改套餐表信息
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    //根据分类id查询套餐信息
    List<Setmeal> setmealByCategoryId(Long categoryId);

    //查询套餐总览
    @Select("select count(id) from setmeal where status=#{status}")
    Integer overviewSetmeals(Integer enable);
}
